In [1]:
import lasio
import os
las = lasio.read(os.path.join("..", "tests", "examples", "6038187_v1.2_short.las"))
The information in a LAS file's header is all parsed and available through the sections of the header.
All the sections are in the dictionary las.sections.
In [2]:
for name, section in las.sections.items():
print((name, type(section)))
These standard section names are hard-coded as attributes, but if your LAS file has non-standard ones they will be in here too.
Only the standard sections are parsed in the LAS format, as a SectionItems object. Others will be left as text, like ~Other.
In [3]:
las.version
Out[3]:
You can use this like a list... or like a dictionary, using the mnemonic= attribute as a key to the dictionary.
for example:
In [4]:
for item in las.version:
print(item)
Or we can pull out an item using the section like a dictionary:
In [5]:
las.version['VERS']
Out[5]:
Or even as an attribute, if the mnemonic allows it:
In [6]:
las.version.VERS
Out[6]:
Each HeaderItem is also itself an attribute dictionary - very easy to get at each property either as an item (dict style) or an attribute:
In [7]:
v = las.version.VERS
v.descr
Out[7]:
In [8]:
v.value
Out[8]:
Moving on to the standard ~Well section of a LAS header.
Let's say we'd like to edit a property. We can do it easily by directly assigning the values:
In [9]:
las.well.CTRY
Out[9]:
In [10]:
las.well.CTRY.descr = 'Australia'
las.well.CTRY
Out[10]:
Now let's have a look at the curves section.
In [11]:
las.curves
Out[11]:
CurveItems are very similar. The only difference is that they have an additional data= attribute.
Notice the units for PR are incorrect - we can fix that:
In [12]:
las.curves.PR.unit = "ohmm"
In [13]:
las.curves["PR"]
Out[13]:
And finally the standard ~Parameter section:
In [14]:
las.params # las.sections["params"] would also work
Out[14]:
If you'd prefer to see a section as a dictionary with the value property, you can with the dictview() method:
In [15]:
las.params.dictview()
Out[15]:
In [ ]:
In [ ]: